import { mdRender  } from "../markDownIt/index";
const fileRegex = /\.(md)$/
const compileFileToJS = (src) => {
  const mdRes = mdRender(src)
  const code = `
  const divEl = document.createElement('div')
  divEl.innerHTML = \`${mdRes}\`
  export default divEl
  `
  return code
}
export default function myPlugin() {
  return {
    name: 'transform-file',
      // enforce: 'pre',
    transform(src, id) {
        console.log(222,id)
      if (fileRegex.test(id)) {
        return {
          code: compileFileToJS(src),
          map: null // 如果可行将提供 source map
        }
      }
    },
  }
}